/*$Id: EclipseCleanMojo.java 5 2010-10-17 00:31:54Z vip.delete $*/

/**
 * Copyright vip_delete
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.eclipseplugin;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;

import java.io.File;
import java.io.IOException;

/**
 * @author vip_delete
 * @goal clean
 * @since 28.07.2010
 */
public class EclipseCleanMojo extends AbstractMojo
{
    /**
     * @parameter expression="${project}"
     * @required
     * @readonly
     */
    private MavenProject project;

    public void execute() throws MojoExecutionException, MojoFailureException
    {
        try
        {
            FileUtils.forceDelete(new File(project.getBasedir(), ".classpath"));
            FileUtils.forceDelete(new File(project.getBasedir(), ".project"));
            FileUtils.forceDelete(new File(project.getBasedir(), ".settings"));
        } catch (IOException e)
        {
            throw new MojoExecutionException(e.getMessage(), e);
        }
    }
}
